package o;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.util.Locale;

public class egd extends egv {
    private boolean ᐝ = false;

    private boolean ˊ() {
        try {
            ApplicationInfo applicationInfo = this.ॱ.getPackageManager().getPackageInfo("com.huawei.appmarket", DnsConfig.MAX_CACHE_ENTRIES).applicationInfo;
            if (applicationInfo == null) {
                return false;
            }
            Bundle bundle = applicationInfo.metaData;
            if (bundle == null || !bundle.containsKey("access_content_restrict")) {
                return false;
            }
            int i = bundle.getInt("access_content_restrict");
            Logger.ˎ("GameRestrictionsManager", "app gallery support value=" + i);
            if (i == 1) {
                return true;
            }
            return false;
        } catch (NameNotFoundException e) {
            Logger.e("GameRestrictionsManager", "PackageManager NameNotFoundException");
            return false;
        }
    }

    public boolean ॱ() {
        return this.ᐝ;
    }

    protected void ˎ(String str) {
        if (ˎ()) {
            Logger.ˎ("GameRestrictionsManager", String.format(Locale.ENGLISH, "onSettingsDBGradeInfoChange  old gradeInfo:%s new gradeInfo:%s", new Object[]{this.ʽ, str}));
            if (ʻॱ()) {
                this.ʽ = str;
                int i = this.ˏ;
                ˏ(ˋ(str));
                ˊ(this.ʽ);
                if (ˊ(i, this.ˏ)) {
                    ॱ(this.ˏ);
                }
            }
        }
    }

    protected void ˎ(int i) {
        if (ˎ()) {
            int i2 = this.ˏ;
            ˋ(i);
            switch (i) {
                case -1:
                case 0:
                    ˉ();
                    break;
                case 1:
                    ˏ();
                    break;
            }
            Logger.ˎ("GameRestrictionsManager", String.format(Locale.ENGLISH, "onSettingsDBMainSwitchChange: oldGradeID:%s newGradeID:%s", new Object[]{Integer.valueOf(i2), Integer.valueOf(this.ˏ)}));
            if (ˊ(i2, this.ˏ)) {
                ॱ(this.ˏ);
            }
        }
    }

    protected void ॱ(int i) {
        Logger.ˏ("GameRestrictionsManager", "onGradeIdDidChange: will reboot");
        ˋˊ();
    }

    protected int ˋ(String str) {
        int parseInt;
        String str2 = "CN";
        if (!TextUtils.isEmpty(str)) {
            String[] split = str.split("\\|");
            if (split.length >= 3) {
                str2 = split[0];
                parseInt = Integer.parseInt(split[1]);
                if ("CN".equalsIgnoreCase(str2)) {
                    return -1;
                }
                return parseInt;
            }
        }
        parseInt = -1;
        if ("CN".equalsIgnoreCase(str2)) {
            return parseInt;
        }
        return -1;
    }

    protected void ʻ() {
        Logger.ˎ("GameRestrictionsManager", String.format(Locale.ENGLISH, "initStatus begin: parentControlSupport:%s agSupport:%s gradeInfo:%s mainSwitchStatus:%s", new Object[]{Boolean.valueOf(this.ʻ), Boolean.valueOf(this.ᐝ), this.ʽ, Integer.valueOf(this.ʼ)}));
    }

    protected boolean ᐝ() {
        return azc.ˎ().ॱ() >= 21 && ॱ();
    }

    protected void ʼ() {
        ʾ();
        this.ˊ = false;
        this.ʼ = -1;
        this.ʽ = ˊᐝ();
        this.ˏ = ˋ(this.ʽ);
        this.ʻ = false;
        this.ᐝ = ˊ();
    }

    protected void ʽ() {
        CharSequence charSequence = this.ʽ;
        ʽॱ();
        this.ʼ = ᐝॱ();
        if (ˎ() && ʻॱ()) {
            this.ʽ = ˈ();
        } else {
            this.ʽ = null;
        }
        this.ˏ = ˋ(this.ʽ);
        if ((!TextUtils.equals(charSequence, this.ʽ) ? 1 : null) != null) {
            ˊ(this.ʽ);
        }
    }

    protected void ˋॱ() {
        CharSequence charSequence = this.ʽ;
        this.ʽ = null;
        this.ˏ = -1;
        if ((!TextUtils.equals(charSequence, this.ʽ) ? 1 : null) != null) {
            ˊ(this.ʽ);
        }
    }

    protected void ॱॱ() {
        this.ˊ = true;
        Logger.ˏ("GameRestrictionsManager", String.format(Locale.ENGLISH, "onStatusInited: parentControlSupport:%s agSupport:%s gradeInfo:%s mainSwitchStatus:%s ", new Object[]{Boolean.valueOf(this.ʻ), Boolean.valueOf(this.ᐝ), this.ʽ, Integer.valueOf(this.ʼ)}));
        if (this.ˋ != null) {
            this.ˋ.onComplete();
            this.ˋ = null;
        }
    }

    public boolean ˎ() {
        return ॱˎ() && ॱ();
    }
}
